package com.thoughtworks.studentManagement.repository;

import com.thoughtworks.studentManagement.model.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

@Repository
public
interface StudentRepository extends JpaRepository<Student, String> {

    @Transactional
    @Modifying
    @Query("update Student s set s.name = :newName where s.studentNumber = :studentNumber")
    Integer updateNameByStudentNumber(@Param("newName") String newName, @Param("studentNumber") String studentNumber);

}